//
//  ViewController.m
//  HTML_use_iOS
//
//  Created by leo on 16/2/20.
//  Copyright © 2016年 leo. All rights reserved.
//

#import "ViewController.h"

@interface ViewController () <UIWebViewDelegate,UINavigationControllerDelegate,UIPickerViewDelegate>
@property (weak, nonatomic) IBOutlet UIWebView *webView;



@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
 
    // 加载网页
    NSURL *url = [[NSBundle mainBundle] URLForResource:@"index" withExtension:@"html"];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [self.webView loadRequest:request];
    
    
}


- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
    
    NSString *str = request.URL.absoluteString;
    
    NSRange range = [str rangeOfString:@"leo://"];
    if (range.location != NSNotFound) {
        // 能找到
        NSString *method = [str substringFromIndex:range.location + range.length];

        NSLog(@"%@", method);
        
//        SEL sel = NSSelectorFromString(method);
//        [self performSelector:sel];
        
    }
    
    
    return YES;
}


#pragma mark - 访问相册
- (void)getImage {
    UIImagePickerController *pickerImg = [[UIImagePickerController alloc] init];
    pickerImg.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    
    [self presentViewController:pickerImg animated:YES completion:nil];
}


@end
